home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / nfbtr731.zip / NFBASM.ASM < prev    next >
Assembly Source File  |  1995-01-24  |  1KB  |  78 lines

  1. ;for medium model
  2. arg1 equ [bp+6]
  3. arg2 equ [bp+8]
  4. arg3 equ [bp+10]
  5. dgroup group _data
  6. assume cs:nfbasm_text,ds:dgroup
  7. nfbasm_text SEGMENT byte public 'CODE'    ;begin code segment
  8. ;void _sound(frequency)
  9. ;int frequency;
  10. public _sound,_nosound,_delay
  11.  
  12. _sound PROC far      ;begin main program
  13.  
  14. ;interface to C
  15.    push  bp
  16.    mov   bp,sp
  17. mov bx,arg1;get frequency
  18. or bx,bx ;is frequency 0?
  19. jz done_sound
  20. mov ax,34ddh
  21. mov dx,0012h
  22. cmp dx,bx
  23. jnb done_sound
  24. div bx
  25. mov bx,ax
  26. in al,61h
  27. test al,03h
  28. jnz a
  29. or al,03h
  30. out 61h,al
  31. mov al,0b6h
  32.        out 43h,al
  33. a:       mov al,bl
  34.        out 42h,al
  35.        mov al,bh
  36.        out 42h,al
  37.        done_sound:
  38.        pop bp
  39. ret
  40. _sound endp
  41.  
  42. _nosound proc far
  43.  
  44. ;interface to C
  45.    push  bp
  46.    mov   bp,sp
  47. ;turn off sound
  48. in al,61h
  49. and al,0fch
  50. out 61h,al
  51. pop bp
  52. ret
  53. _nosound endp
  54.  
  55. _delay proc far
  56. push bp
  57. mov bp,sp
  58. mov cx,arg1 ;get duration
  59. jcxz exit_delay
  60. again:
  61. push cx
  62. mov cx, _timer
  63. again1:loop again1
  64. pop cx
  65. loop again
  66. exit_delay:
  67.       pop bp
  68. ret
  69. _delay endp
  70.  
  71. nfbasm_text ends ;end of code segment
  72.  
  73. _data segment byte public 'DATA'
  74. extrn _timer:word
  75. _data ends
  76. end
  77.  
  78.